from pymongo import MongoClient


def mongo_conn():
    # Create a connection using MongoClient. You can import MongoClient or use pymongo.MongoClient
    client = MongoClient("mongodb://localhost:26800")
    # Create the database for our example (we will use the same database throughout the tutorial
    return client['data']  # 指定数据库


# This is added so that many files can reuse the function get_database()
if __name__ == "__main__":
    # Get the database
    dbname = mongo_conn()
    print(dbname.list_collection_names())
